import { customRequest } from "../request/custom";
import { get, post } from "../request/request";

/**
 * 根据token获取用户信息
 * @param callback
 */
export const fetchUpdateToken = async (callback?: () => void | boolean) => {
  return customRequest(() => get("/api/user/msg/token"), callback);
};

/**
 * 注册
 * @param formData
 * @param callback
 */
export const fetchRegister = async (formData: {}, callback?: () => void | boolean) => {
  return customRequest(() => post("/api/user", formData), callback);
};

/**
 * 登录
 * @param formData
 * @param callback
 */
export const fetchLogIn = async (formData: {}, callback?: () => void | boolean) => {
  return customRequest(() => post("/api/auth", formData), callback);
};

/**
 * 发送验证码
 * @param params
 * @param callback 
 */
export const fetchSendCode = async (params:{}, callback?: () => void | boolean) => {
  return customRequest(
    () => get("/api/auth/sendcode", params ),
    callback
  );
};
/**
 * 短信登录
 * @param formData 
 * @param callback 
 */
export const fetchPhoneLogin = async (formData:{}, callback?: () => void | boolean) => {
  return customRequest(() => post("/api/auth/login/code", formData), callback);
};